Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
markdown-it-emoji
Advanced tools
The markdown-it-emoji package is a plugin for the markdown-it Markdown parser that allows you to easily include emoji in your Markdown documents. It converts emoji shortcodes (like :smile:) into their corresponding Unicode emoji characters.
Basic Emoji Conversion
This feature allows you to convert emoji shortcodes into their corresponding Unicode emoji characters. By using the markdown-it-emoji plugin with markdown-it, you can easily include emojis in your Markdown content.
const md = require('markdown-it')();
const emoji = require('markdown-it-emoji');
md.use(emoji);
const result = md.render('I :heart: Markdown!');
console.log(result); // Outputs: <p>I ❤️ Markdown!</p>
Custom Emoji Definitions
This feature allows you to define custom emoji shortcodes and their corresponding Unicode characters. You can extend or override the default emoji definitions provided by the plugin.
const md = require('markdown-it')();
const emoji = require('markdown-it-emoji');
md.use(emoji, {
defs: {
smile: '😃',
custom_emoji: '🚀'
}
});
const result = md.render('I :smile: using :custom_emoji:!');
console.log(result); // Outputs: <p>I 😃 using 🚀!</p>
Custom Emoji Rendering
This feature allows you to customize the rendering of emojis. You can define how the emojis should be rendered in the final HTML output, such as wrapping them in custom HTML tags or adding CSS classes.
const md = require('markdown-it')();
const emoji = require('markdown-it-emoji');
md.use(emoji, {
shortcuts: {
angry: [':angry:', '>:(']
},
renderer: function (token, idx) {
return '<span class="emoji emoji-' + token[idx].markup + '">' + token[idx].content + '</span>';
}
});
const result = md.render('I am >:( right now!');
console.log(result); // Outputs: <p>I am <span class="emoji emoji-angry">😠</span> right now!</p>
The emojione package provides a comprehensive set of emoji images and a JavaScript library for converting emoji shortcodes, Unicode characters, and ASCII emoticons into emoji images. Compared to markdown-it-emoji, emojione offers more customization options for rendering emojis as images rather than Unicode characters.
The emoji-dictionary package provides a simple way to look up emoji characters by their names or shortcodes. It is more focused on providing a dictionary of emojis rather than integrating with Markdown parsing, making it a more lightweight option compared to markdown-it-emoji.
The markdown-it package is a Markdown parser that can be extended with plugins like markdown-it-emoji. While markdown-it itself does not provide emoji support out of the box, it serves as the foundation for adding such functionality through plugins.
Plugin for markdown-it markdown parser, adding emoji & emoticon syntax support.
v1.+ requires markdown-it
v4.+, see changelog.
Two versions:
Also supports emoticons shortcuts like :)
, :-(
, and others. See the full list in the link above.
node.js, browser:
npm install markdown-it-emoji --save
bower install markdown-it-emoji --save
var md = require('markdown-it')();
var emoji = require('markdown-it-emoji');
// Or for light version
// var emoji = require('markdown-it-emoji/light');
md.use(emoji [, options]);
Options are not mandatory:
{ name1: char1, name2: char2, ... }
{ "smile": [ ":)", ":-)" ], "laughing": ":D" }
Differences in browser. If you load the script directly into the page without
using a package system, the module will add itself globally with the name markdownitEmoji
.
Init code will look a bit different in this case:
var md = window.markdownit().use(window.markdownitEmoji);
By default, emojis are rendered as appropriate unicode chars. But you can change the renderer function as you wish.
Render as span blocks (for example, to use a custom iconic font):
// ...
// initialize
md.renderer.rules.emoji = function(token, idx) {
return '<span class="emoji emoji_' + token[idx].markup + '"></span>';
};
Or use twemoji:
// ...
// initialize
var twemoji = require('twemoji')
md.renderer.rules.emoji = function(token, idx) {
return twemoji.parse(token[idx].content);
};
NB 1. Read twemoji docs! In case you need more options to change image size & type.
NB 2. When using twemoji you can make image height match the line height with this style:
.emoji {
height: 1.2em;
}
FAQs
Emoji plugin for markdown-it markdown parser.
The npm package markdown-it-emoji receives a total of 334,009 weekly downloads. As such, markdown-it-emoji popularity was classified as popular.
We found that markdown-it-emoji demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.